<#include "/common/head.html"/>

<table id="dg" class="easyui-datagrid" 
        data-options="
        	rownumbers:true,
        	fit:true,
        	border:false,
        	rownumbers:true,
        	
        	url:'genFormData',
        	method:'get',
        	toolbar:'#tb',
        	pagination:true">
    <thead>
        <tr>
            <th data-options="field:'TABLE_SCHEMA',width:130">数据库</th>
            <th data-options="field:'TABLE_TYPE',width:180">表名</th>
            <th data-options="field:'TABLE_NAME',width:120">表类型</th>
            <th data-options="field:'TABLE_COMMENT',width:130">表说明</th>
            <th data-options="field:'CREATE_TIME',width:130">创建时间</th>
        </tr>
    </thead>
</table>
<div id="tb" style="padding:2px 5px;">
    <div class="wrap_search">
        <span class="search_item" style="padding: 4px;">
            <span class="item_text">数据库: </span>
            <span class="item_obj">
                <input class="easyui-textbox" type="text" name="TABLE_SCHEMA" />
            </span>    
        </span>
        <span class="search_item" style="padding: 4px;">
            <span class="item_text">表名: </span>
            <span class="item_obj">
                <input class="easyui-textbox" type="text" name="TABLE_NAME" />
            </span>    
        </span>
        <span class="search_item" style="text-align: right; padding: 4px;">
            <a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="zcurdSearch(this)">搜索</a>　　　　　　
        </span>
    </div>
</div>

<script type="text/javascript">
top.window.subPage.save = function() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	$.post("genForm", {tableName: rowsSel[0].TABLE_NAME}, function(data) {
		if(data.result == "success") {
			showMsg("表单生成成功！");
			top.window.closeWindow();
			top.window.subPage.loadCurrDatagrid();
		}
	});	
}

var datagrid = $("#dg");
function zcurdSearch() {
	var param = zcurdGetParam();
	log(param);
	datagrid.datagrid("load", {
		queryParams: param
	})
}

function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val();	
		}
	});
	return param;
}
</script>

<#include "/common/foot.html"/>